const Sequelize = require("sequelize");
const moment = require("moment");
const tag = (sequelize, DataTypes) => {
   return sequelize.define(
     "tag",
     {
       id: {
         type: DataTypes.INTEGER(11),
         primaryKey: true,
         autoIncrement: true,
       },
       name: {
         type: Sequelize.STRING,
         unique: {
           msg: "已添加",
         },
         field: "name"
       },
       createdAt: {
         type: Sequelize.DATE,
         defaultValue: Sequelize.NOW,
         get() {
           return moment(this.getDataValue("createdAt")).format(
             "YYYY-MM-DD HH:mm"
           );
         },
       },
       updatedAt: {
         type: Sequelize.DATE,
         defaultValue: Sequelize.NOW,
         get() {
           return moment(this.getDataValue("updatedAt")).format(
             "YYYY-MM-DD HH:mm"
           );
         },
       },
     },
     {
       freezeTableName: true,
     }
   );
}
module.exports = tag;
